package com.example.administrator.dagger2demo.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.example.administrator.dagger2demo.R;

import in.srain.cube.views.ptr.PtrClassicFrameLayout;

/**
 * Created by Administrator on 2015/11/18.
 */
public class FragmentIIIII extends BaseFragment {
    public static final String ARG_PAGE = "ARG_PAGE";
    private int mPage;
    private View layout;
    private final int FIRST_FRAGMENT = 0;
    private final int SECOND_FRAGMENT = 1;
    private final int THIRD_FRAGMENT = 2;
    private int mCurIndex = -1;
    /**
     * 标志位，标志已经初始化完成
     */
    private boolean isPrepared;
    /**
     * 是否已被加载过一次，第二次就不再去请求数据了
     */
    private boolean mHasLoadedOnce;
    RelativeLayout relativeLayout;
    LinearLayout fabtoolbar_toolbar;
    TabLayout sliding_tabs;

    private ItemTouchHelper mItemTouchHelper;
    RecyclerView recycler_view;
    PtrClassicFrameLayout mPtrFrame;

    public static FragmentIIIII newInstance(Bundle args) {
        FragmentIIIII pageFragment = new FragmentIIIII();
        pageFragment.setArguments(args);
        return pageFragment;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        //1.
        super.onCreate(savedInstanceState);
        mPage = getArguments().getInt(ARG_PAGE);
        Log.e("TAG", "onCreate=IIIII");
    }





    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //2.
        if (layout == null) {
            Log.e("TAG", "onCreateView-if-IIIII");
            layout = inflater.inflate(R.layout.fragment_i, container, false);
            Bundle bundle = getArguments();
            if (bundle != null) {
                Log.e("TAG", "bundle-if-IIIII");
                mCurIndex = bundle.getInt(ARG_PAGE);
            }
            isPrepared = true;
            lazyLoad();
        }
        Log.e("TAG", "onCreateView-end-IIIII");
        return layout;
    }
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //3.
        Log.e("TAG", "onViewCreated=IIIII");

    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //4.
        Log.e("TAG", "onActivityCreated-IIIII");

    }



    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e("TAG", "onDestroy-end-IIIII");
    }
    @Override
    protected void lazyLoad() {
        if (!isPrepared || !isVisible || mHasLoadedOnce) {
            return;
        }
        Log.e("TAG", "lazyLoad-IIIII");
    }
}
